<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 文件服务器</title>
    <meta name="keywords" content="ZDH 文件服务器">
    <meta name="description" content="ZDH 文件服务器">

    <link rel="shortcut icon" href="img/favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">

            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>文件服务器</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="signupForm">

                            <div class="form-group">
                                <label class="col-sm-3 control-label">用户名：</label>
                                <div class="col-sm-8">
                                    <input id="username" name="username" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">密码：</label>
                                <div class="col-sm-8">
                                    <input id="password" name="password" class="form-control" type="password">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">确认密码：</label>
                                <div class="col-sm-8">
                                    <input id="confirm_password" name="confirm_password" class="form-control" type="password">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">IP：</label>
                                <div class="col-sm-8">
                                    <input id="host" name="host" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">PORT：</label>
                                <div class="col-sm-8">
                                    <input id="port" name="port" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">本地服务器路径：</label>
                                <div class="col-sm-8">
                                    <input id="tmp_dir" name="tmp_dir" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">NGINX路径：</label>
                                <div class="col-sm-8">
                                    <input id="nginx_dir" name="nginx_dir" class="form-control" type="text" aria-required="true" aria-invalid="true" class="error">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="button" id="btn_up" οnsubmit='return false'>更新</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>


    <script src="js/zdh_common.js"></script>
    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="js/content.js?v=1.0.0"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="js/plugins/validate/jquery.validate.min.js"></script>
    <script src="js/plugins/validate/messages_zh.min.js"></script>

    <!-- layer javascript -->
    <script src="js/plugins/layer/layer.min.js"></script>

    <script>

        (function(document, window, $) {

            $.ajax({
                type: 'POST',
                url: server_context+"/getFileManager",
                async:false,
                dataType: 'json',
                data: '',
                //成功返回
                success: function (data) {
                    if(data.code != "200"){
                        layer.msg(data.msg);
                        return ;
                    }
                    if(data.result.username !='' ){
                        $('#username').val(data.result.username);
                        $('#password').val(data.result.password);
                        $('#host').val(data.result.host);
                        $('#port').val(data.result.port);
                        $('#tmp_dir').val(data.result.tmp_dir);
                        $('#nginx_dir').val(data.result.nginx_dir);
                    }
                },
                //处理完成
                complete: function () {
                    console.info("complete getUserInfo")
                },
                //报错
                error: function (data) {
                    console.info("error: " + data.responseText);
                }
            });


            $('#btn_up').click(function () {

                if($('#password').val() != $('#confirm_password').val()){
                    layer.msg("2次密码不一致,请检查密码");
                    return ;
                }

                $.ajax({
                    type: 'POST',
                    url: server_context+"/file_manager_up",
                    dataType: 'json',
                    data: $("#signupForm").serialize(),
                    //发送数据前
                    beforeSend: function () {
                        // 禁用按钮防止重复提交
                        $("#btn_up").attr({disabled: "disabled"});
                    },
                    //成功返回
                    success: function (data) {
                        $("#btn_up").removeAttr('disabled');
                        if(data.code != "200"){
                            layer.msg(data.msg);
                            return ;
                        }
                        layer.msg('更新成功', {
                            time: 5000, //20s后自动关闭
                            btn: ['明白了,5s后自动关闭']
                        },function () {
                            $(".J_menuTab.active",window.top.document).find(".fa.fa-times-circle").click();
                        });
                    },
                    //处理完成
                    complete: function () {
                        $("#btn_up").removeAttr('disabled');
                        console.info("complete")
                    },
                    //报错
                    error: function (data) {
                        $("#btn_up").removeAttr('disabled');
                        layer.msg(data.responseText);
                        console.info("error: " + data.responseText);
                    }
                });


            })

        })(document, window, jQuery);


    </script>

</body>



</html>
